package com.ruoyi.asset.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.asset.domain.AssetFlowType;
import com.ruoyi.asset.service.IAssetFlowTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工单流程Controller
 * 
 * @author yepanpan
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/asset/flowType")
public class AssetFlowTypeController extends BaseController
{
    @Autowired
    private IAssetFlowTypeService assetFlowTypeService;


    /**
     * 查询工单流程列表
     */
    @GetMapping("/select")
    public AjaxResult select(AssetFlowType assetFlowType)
    {
        List<AssetFlowType> list = assetFlowTypeService.selectAssetFlowTypeList(assetFlowType);
        return success(list);
    }

    /**
     * 查询工单流程列表
     */
    @PreAuthorize("@ss.hasPermi('asset:flowType:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssetFlowType assetFlowType)
    {
        startPage();
        List<AssetFlowType> list = assetFlowTypeService.selectAssetFlowTypeList(assetFlowType);
        return getDataTable(list);
    }

    /**
     * 导出工单流程列表
     */
    @PreAuthorize("@ss.hasPermi('asset:flowType:export')")
    @Log(title = "工单流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssetFlowType assetFlowType)
    {
        List<AssetFlowType> list = assetFlowTypeService.selectAssetFlowTypeList(assetFlowType);
        ExcelUtil<AssetFlowType> util = new ExcelUtil<AssetFlowType>(AssetFlowType.class);
        util.exportExcel(response, list, "工单流程数据");
    }

    /**
     * 获取工单流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('asset:flowType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(assetFlowTypeService.selectAssetFlowTypeById(id));
    }

    /**
     * 新增工单流程
     */
    @PreAuthorize("@ss.hasPermi('asset:flowType:add')")
    @Log(title = "工单流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssetFlowType assetFlowType)
    {
        return toAjax(assetFlowTypeService.insertAssetFlowType(assetFlowType));
    }

    /**
     * 修改工单流程
     */
    @PreAuthorize("@ss.hasPermi('asset:flowType:edit')")
    @Log(title = "工单流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssetFlowType assetFlowType)
    {
        return toAjax(assetFlowTypeService.updateAssetFlowType(assetFlowType));
    }

    /**
     * 删除工单流程
     */
    @PreAuthorize("@ss.hasPermi('asset:flowType:remove')")
    @Log(title = "工单流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assetFlowTypeService.deleteAssetFlowTypeByIds(ids));
    }
}
